# -*- coding = utf-8 -*-
# @Time : 2021/7/14 16:56
# @Author : 龙王赘婿_彪少
# @File : testUrllib3.py
# @Software: PyCharm

import urllib.request
import urllib.parse
#超时处理
try:
    response = urllib.request.urlopen("http://httpbin.org/get", timeout = 0.1)
    #返回了一个对象
    # print(response)
    #调用成员函数，read() 将其保存在.html文件中可访问
    print(response.read().decode('utf-8'))
except urllib.error.URLError as e:
    print("time out!")

'''
    "User-Agent": "Python-urllib/3.7",
    这个地方就告诉了别人，我就是个爬虫
'''